import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '所属风险事件',
    align:"center",
    dataIndex: 'riskEventId_dictText'
  },
  {
    title: '管控方式',
    align:"center",
    dataIndex: 'dataSrc_dictText'
  },
  {
    title: '管控措施描述',
    align:"center",
    dataIndex: 'riskMeasureDesc'
  },
  {
    title: '隐患排查内容',
    align:"center",
    dataIndex: 'troubleshootContent'
  },
  {
    title: '管控措施1',
    align:"center",
    dataIndex: 'classify1_dictText'
  },
  {
    title: '管控措施2',
    align:"center",
    dataIndex: 'classify2_dictText'
  },
  {
    title: '管控措施3',
    align:"center",
    dataIndex: 'classify3'
  },
  {
    title: '人员岗位',
    align:"center",
    dataIndex: 'personnelPosition'
  },
  {
    title: '排查周期',
    align:"center",
    dataIndex: 'period'
  },
  {
    title: '周期单位',
    align:"center",
    dataIndex: 'periodUnit_dictText'
  },
  {
    title: '数据来源',
    align:"center",
    dataIndex: 'source_dictText'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "管控方式",
    field: "dataSrc",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"data_src"
    },
    //colProps: {span: 6},
  },
  {
    label: "管控措施描述",
    field: "riskMeasureDesc",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "隐患排查内容",
    field: "troubleshootContent",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "管控措施1",
    field: "classify1",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"tb_base_control_measures_type,name,id,pid='0'"
    },
    //colProps: {span: 6},
  },
  {
    label: "管控措施2",
    field: "classify2",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"tb_base_control_measures_type,name,id,pid!='0'"
    },
    //colProps: {span: 6},
  },
  {
    label: "管控措施3",
    field: "classify3",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "人员岗位",
    field: "personnelPosition",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "排查周期",
    field: "period",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "周期单位",
    field: "periodUnit",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"period_type"
    },
    //colProps: {span: 6},
  },
  {
    label: "数据来源",
    field: "source",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"source_type"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '管控方式',
    field: 'dataSrc',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"data_src"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入管控方式!'},
      ];
     },
  },
  {
    label: '管控措施描述',
    field: 'riskMeasureDesc',
    component: 'InputTextArea',//TODO 注意string转换问题
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入管控措施描述!'},
      ];
     },
  },
  {
    label: '隐患排查内容',
    field: 'troubleshootContent',
    component: 'InputTextArea',//TODO 注意string转换问题
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入隐患排查内容!'},
      ];
     },
  },
  {
    label: '管控措施1',
    field: 'classify1',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"tb_base_control_measures_type,name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入管控措施1!'},
      ];
     },
  },
  {
    label: '管控措施2',
    field: 'classify2',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"tb_base_control_measures_type,name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入管控措施2!'},
      ];
     },
  },
  {
    label: '管控措施3',
    field: 'classify3',
    component: 'InputTextArea',//TODO 注意string转换问题
  },
  // {
  //   label: '删除标志',
  //   field: 'deleted',
  //   component: 'JDictSelectTag',
  //   componentProps:{
  //     dictCode:"yn"
  //   },
  // },
  {
    label: '人员岗位',
    field: 'personnelPosition',
    component: 'Input',
  },
  {
    label: '排查周期',
    field: 'period',
    component: 'InputNumber',
  },
  {
    label: '周期单位',
    field: 'periodUnit',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"period_type"
    },
  },
  {
    label: '数据来源',
    field: 'source',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"source_type"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入数据来源!'},
      ];
     },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
	field: 'id',
	component: 'Input',
	show: false
  },
];

//子表列表数据
export const tbBaseMeasuresTaskColumns: BasicColumn[] = [
  {
    title: '分配方式',
    align:"center",
    dataIndex: 'type_dictText'
  },
  {
    title: '排查周期',
    align:"center",
    dataIndex: 'period'
  },
  {
    title: '周期单位',
    align:"center",
    dataIndex: 'periodUnit_dictText'
  },
  {
    title: '初始排查时间',
    align:"center",
    dataIndex: 'startTime'
  },
  {
    title: '工作日历',
    align:"center",
    dataIndex: 'calendar_dictText'
  },
  {
    title: '排查人',
    align:"center",
    dataIndex: 'identifyPeople_dictText'
  },
  {
    title: '排查岗位',
    align:"center",
    dataIndex: 'identifyStation_dictText'
  },
  {
    title: '工作开始日期',
    align:"center",
    dataIndex: 'workBeginTime'
  },
  {
    title: '工作结束日期',
    align:"center",
    dataIndex: 'workEndTime'
  },
  // {
  //   title: '最近下发时间',
  //   align:"center",
  //   dataIndex: 'latestTime'
  // },
  {
    title: '任务类型',
    align:"center",
    dataIndex: 'workType_dictText'
  },
  {
    title: '包保任务对应项',
    align:"center",
    dataIndex: 'taskNum_dictText'
  },
  // {
  //   title: '删除标志',
  //   align:"center",
  //   dataIndex: 'deleted_dictText'
  // },
];
//子表表单数据
export const tbBaseMeasuresTaskFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '分配方式',
    field: 'type',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"distribution_type"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入分配方式!'},
      ];
    },
  },
  {
    label: '排查周期',
    field: 'period',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入排查周期!'},
      ];
    },
  },
  {
    label: '周期单位',
    field: 'periodUnit',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"period_type"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入周期单位!'},
      ];
    },
  },
  {
    label: '初始排查时间',
    field: 'startTime',
    component: 'DatePicker',
    componentProps: {
      showTime:true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入初始排查时间!'},
      ];
    },
  },
  {
    label: '工作日历',
    field: 'calendar',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"calendar_type"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入工作日历!'},
      ];
    },
  },
  {
    label: '排查人',
    field: 'identifyPeople',
    component: 'JSelectUser',
    componentProps:{
      labelKey:'realname',
    },
  },
  {
    label: '排查岗位',
    field: 'identifyStation',
    component: 'JSearchSelect',
    componentProps:{
      dict:"sys_position,name,code"
    },
  },
  {
    label: '工作开始日期',
    field: 'workBeginTime',
    component: 'Input',
  },
  {
    label: '工作结束日期',
    field: 'workEndTime',
    component: 'Input',
  },
  {
    label: '最近下发时间',
    field: 'latestTime',
    component: 'DatePicker',
    componentProps: {
      showTime:true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
  {
    label: '任务类型',
    field: 'workType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"risk_work_type"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入任务类型!'},
      ];
    },
  },
  {
    label: '包保任务对应项',
    field: 'taskNum',
    component: 'JSearchSelect',
    componentProps:{
      dict:"tb_defend_risk_task_num,content,code"
    },
  },
  {
    label: '删除标志',
    field: 'deleted',
    component: 'Input',
    dynamicDisabled:true,
  },
];

// 高级查询数据
export const superQuerySchema = {
  dataSrc: {title: '管控方式',order: 0,view: 'list', type: 'string',dictCode: 'data_src',},
  riskMeasureDesc: {title: '管控措施描述',order: 1,view: 'textarea', type: 'string',},
  troubleshootContent: {title: '隐患排查内容',order: 2,view: 'textarea', type: 'string',},
  classify1: {title: '管控措施1',order: 3,view: 'list', type: 'string',dictTable: "tb_base_control_measures_type", dictCode: 'id', dictText: 'name',},
  classify2: {title: '管控措施2',order: 4,view: 'list', type: 'string',dictTable: "tb_base_control_measures_type", dictCode: 'id', dictText: 'name',},
  classify3: {title: '管控措施3',order: 5,view: 'textarea', type: 'string',},
  deleted: {title: '删除标志',order: 6,view: 'radio', type: 'string',},
  personnelPosition: {title: '人员岗位',order: 7,view: 'text', type: 'string',},
  period: {title: '排查周期',order: 8,view: 'number', type: 'number',},
  periodUnit: {title: '周期单位',order: 9,view: 'list', type: 'string',dictCode: 'period_type',},
  source: {title: '数据来源',order: 10,view: 'list', type: 'string',dictCode: 'source_type',},
};
